function convertToStarsArray(stars) {    //3,0
    var num = stars.toString().substring(0, 1);  //3
    var array = [];
    for (var i = 0; i <= 5; i++) {
        if (i <= num) {
            array.push(1);
        }
        else {
            array.push(0);
        }
    }
    return array;
}

module.exports = {
    convertToStarsArray: convertToStarsArray
}

//获取数据的公共方法
function http(url, callBack) {
    wx.request({
        url: url,
        method: 'GET',
        header: {
            "Content-Type": "json"
        },
        success: function (res) {
            callBack(res.data);
        },
        fail: function (error) {
            console.log(error)
        }
    })
}
//处理电影详情页数据的方法
function convertToCastInfos(casts) {
  var castsArray = []
  for (var idx in casts) {
    var cast = {
      img: casts[idx].avatars ? casts[idx].avatars.large : "",
      name: casts[idx].name
    }
    castsArray.push(cast);
  }
  return castsArray;
}
module.exports = {
    convertToStarsArray: convertToStarsArray,
    http: http
}